$(document).ready(function () {
    if (document.body.clientWidth < 768) {
        $(".carousel-inner > .item > img").css("height", "250px");
        $(".carousel .item").css("height", "250px");
        $(".carousel").css("height", "250px");
        $("#myCarousel").css("height", "250px");
        var img_circle = document.getElementsByClassName("img-circle");
        for (var i = 0; i < img_circle.length; i++) {
            img_circle[i].setAttribute("width", "70px");
            img_circle[i].setAttribute("height", "70px");
        }
    } else {
        $(".carousel-inner > .item > img").css("height", "500px");
        $(".carousel .item").css("height", "500px");
        $(".carousel").css("height", "500px");
        $("#myCarousel").css("height", "500px");
        var img_circle = document.getElementsByClassName("img-circle");
        for (var i = 0; i < img_circle.length; i++) {
            img_circle[i].setAttribute("width", "140px");
            img_circle[i].setAttribute("height", "140px");
        }
    }


    albumListApp = new Vue({
        el: '#albumListId',
        data: {
            albumList: []
        },
        created: function () {
            this.initAlbum();
        },
        methods: {
            initAlbum: function () {
                $.ajax({
                    url: "/album/getalbumlist",
                    dataType: "json",
                    type: "POST",
                    success: function (result) {
                        if (result.success) {
                            var dataArr = [];
                            var data = result.data;
                            var html = "<ul>"
                            for (var i = 0; i < data.length; i++) {
                                var dataMap = {
                                    imageUrl: (data[i].fileBeanList.length <= 1) ? "image/picNone.png" : (data[i].fileBeanList[0].fileurl == null ? data[i].fileBeanList[1].fileurl : data[i].fileBeanList[0].fileurl),
                                    albumId: data[i].albumid,
                                    imageCount: data[i].fileBeanList.length - 1,
                                    albumName: data[i].albumname,
                                    primarirycountTotal: data[i].primarirycountTotal,
                                    username: data[i].username,
                                    showAlbumUrl: "album/showAlbum.html?albumId=" + data[i].albumid + "&albumName=" + data[i].albumname +
                                        "&albumpower=" + data[i].albumpower,
                                    // editAlbumUrl: "editAlbum.html?albumId=" + data[i].albumid+"&albumName="+data[i].albumname+
                                    //         "&albumintro="+data[i].albumintro+"&albumpower="+data[i].albumpower,
                                    albumintro: data[i].albumintro,
                                    isShow: false,
                                    albumpower: data[i].albumpower
                                };
                                dataArr.push(dataMap);
                            }
                            albumListApp.albumList = dataArr;

                        } else {
                            layer.msg("失败", {icon: 2})
                        }
                    },
                    error: function (result) {
                        layer.msg("系统繁忙", {icon: 2})
                    }
                });
            },
            photoListEnter: function (param) {
                this.albumList[param].isShow = true;
            },
            photoListLeave: function (param) {
                this.albumList[param].isShow = false;
            },
            editAlbumClick: function (album, indexAlbum) {
                editAlbumIndex = layer.open({
                    title: "编辑相册",
                    type: 2,
                    area: ['700px', '450px'],
                    fixed: false, //不固定
                    maxmin: true,
                    btn: ['确定', '取消'],
                    content: "editAlbum.html?albumId=" + album.albumId + "&albumName=" + album.albumName + "&albumintro=" + album.albumintro + "&albumpower=" + album.albumpower,
                    yes: function (index, layero) {
                        var iframeWin = window[layero.find('iframe')[0].name];
                        iframeWin.saveEditAlbumInfo(indexAlbum);
                    },
                    btn2: function (index, layero) {
                        layer.close(index);
                    },
                    cancel: function () {
                        //右上角关闭回调

                        //return false 开启该代码可禁止点击该按钮关闭
                    }
                });
            },
            deleteAlbumClick: function (album, indexAlbum) {
                // deleteAlbum(album, indexAlbum)
                alert()
            }
        }
    });
});
